﻿/*                       NOTICE
 * 
 * This software was produced for the U. S. Government
 * under Contract No. FA8721-10-C-0001, and is
 * subject to the Rights in Noncommercial Computer Software
 * and Noncommercial Computer Software Documentation Clause
 * (DFARS) 252.227-7014 (JUN 1995)
 * 
 * Approved for Public Release: 11-2435
 * © 2011 The MITRE Corporation. All Rights Reserved. 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */



using System;

using System.Drawing;

using GestureListenerClient.Services;
using GestureListenerClient.Services.Delegates;
namespace Testing
{
    class Program
    {


        static void Main(string[] args)
        {
            GestureClient client;
            if (args.Length == 0)
                client = new GestureClient("FalconView", @"..\..\..\..\..\..\config.txt");
            else
                client = new GestureClient("FalconView", args[0]);

            TapGestureDelegate tgd = new TapGestureDelegate();
            SlideGestureDelegate sgd = new SlideGestureDelegate();
            FiducialObjectDelegate fiducial = new FiducialObjectDelegate();
            HoldSlideGestureDelegate holdslide = new HoldSlideGestureDelegate();
            HoldGestureDelegate hold = new HoldGestureDelegate();

            holdslide.OnHoldSlideChange += new GestureCallbackDelegate.OnGestureDelegate(pull_OnPullingGesture);
            tgd.OnTap += new GestureCallbackDelegate.OnGestureDelegate(tapTest);
            sgd.OnSlideChange += new GestureCallbackDelegate.OnGestureDelegate(sgd_OnSlidingGesture);
            fiducial.OnObjectAdded += new FiducialCallbackDelegate.OnFiducialDelegate(fiducial_OnObjectAdded);
            hold.OnHoldGesture += new GestureCallbackDelegate.OnGestureDelegate(hold_OnHoldGesture);
            
            client.registerListener(new GestureListenerClient.Services.ListenerRegistration("Hello!", new RectangleF(0, 0, 50, 50), tgd));
            client.registerListener(new GestureListenerClient.Services.ListenerRegistration("Hello!", new RectangleF(0, 0, 50, 50), sgd));
            client.registerListener(new GestureListenerClient.Services.ListenerRegistration("Hello!", new RectangleF(0, 0, 50, 50), fiducial));
            client.registerListener(new GestureListenerClient.Services.ListenerRegistration("Hello!", new RectangleF(0, 0, 50, 50), holdslide));
            client.registerListener(new GestureListenerClient.Services.ListenerRegistration("Hello!", new RectangleF(0, 0, 50, 50), hold));

            //string resp = GestureListenerClient.Services.HTTP.HTTPClient.post(new Uri("http://MM178187-PC:8080"), "<gestures><gesture type=\"TapGesture\" time=\"12/31/2009 11:59:59\"><coordinates><coordinate x=\"50.532\" y=\"55\"/></coordinates><prevGestures></prevGestures></gesture><gesture index=\"1\" type=\"SlidingGesture\" time=\"12/31/2010 23:59:59\"><coordinates><coordinate x=\"50.532\" y=\"12\"/><coordinate x=\"10\" y=\"15\"/></coordinates><prevGestures><prevGesture type=\"SlideGestureStart\" time=\"12/31/2010 23:59:50\"><coordinate x=\"50.532\" y=\"12\"/><coordinate x=\"80.532\" y=\"19\"/><coordinate x=\"20.532\" y=\"90\"/><coordinate x=\"90.532\" y=\"15\"/></prevGesture><prevGesture type=\"SlidingGesture\" time=\"12/31/2010 23:59:55\"><coordinate x=\"10\" y=\"15\"/></prevGesture></prevGestures></gesture></gestures>");
            Console.ReadKey();

            client.destroy();

        }

        static void hold_OnHoldGesture(object source, GestureArgs e)
        {
            Console.Write("got a new hold");
        }

        static void pull_OnPullingGesture(object source, GestureArgs e)
        {
            Console.Write("got a new pull");
        }

        static void fiducial_OnObjectAdded(object source, FiducialArgs e)
        {
            Console.Write("got a new object");
        }

        static void sgd_OnSlidingGesture(object source, GestureArgs e)
        {
            Console.Write("got a slide");
        }

       
        private static void tapTest(object source, GestureListenerClient.Services.Delegates.GestureArgs e)
        {
            Console.Write("got a tap");
        }
    }
}
